# -*- coding: utf-8 -*-
"""
Created on Sun Jun  1 16:00:35 2025

@author: micha
"""

import pandas as pd
pd.options.plotting.backend = "plotly"
import plotly.io as pio
import plotly.graph_objects as go

#send plots to current browser. Export from browser as .png
pio.renderers.default='browser'


Data_DF = pd.read_excel("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/input data/Sturgeon Johnson CC.xlsx")

#Data_DF = Data_DF.head(20)

#create go Figure
fig = go.Figure()


#Sturgeon Trace
fig.add_trace(go.Bar(
            name= 'Sturgeon',
            x=Data_DF['Sturgeon-Upper']-Data_DF['Sturgeon-lower'],
            y=Data_DF['Number of Words'],
            base=Data_DF['Sturgeon-lower'],
            orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

#Johnson Trace
fig.add_trace(go.Bar(
            name='Johnson',
            x=Data_DF['Johnson-upper']-Data_DF['Johnson-lower'],
            y=Data_DF['Number of Words'],
            base=Data_DF['Johnson-lower'],
            orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

fig.update_xaxes(title='Conceptual Complexity')
fig.update_yaxes(title= 'Number of Words')
fig.update_traces(opacity=0.3)
fig.update_layout(barmode='overlay')


fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/Sturgeon and Johnson CC confidence intervals.svg", format='svg',scale=2, engine='orca')

# Schotthofer 2024
Data_DF = pd.read_excel("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/input data/Schotthöfer 2024 Clinton.xlsx")

#create go Figure
fig = go.Figure()

#Clinton P1 Trace
fig.add_trace(go.Bar(
            name= 'Clinton P1',
            y=Data_DF['Clinton Upper P1']-Data_DF['Clinton Lower P1'],
            x=Data_DF['Date'],
            base=Data_DF['Clinton Lower P1'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

#Clinton P1 means Trace
fig.add_trace(go.Scatter(
            name= 'Clinton P1 means',
            y=Data_DF['Clinton P1'],
            x=Data_DF['Date'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))


fig.update_traces(opacity=0.3)
fig.update_layout(bargap=0.5)
fig.update_layout(width=400)
fig.update_yaxes(title= 'P1')

fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/Clinton P1 confidence intervals.svg", format='svg',scale=2, engine='orca')

#create go Figure
fig = go.Figure()

#Clinton I1 Trace
fig.add_trace(go.Bar(
            name= 'Clinton I1',
            y=Data_DF['Clinton Upper I1']-Data_DF['Clinton Lower I1'],
            x=Data_DF['Date'],
            base=Data_DF['Clinton Lower I1'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

#Clinton I1 means Trace
fig.add_trace(go.Scatter(
            name= 'Clinton I1 means',
            y=Data_DF['Clinton I1'],
            x=Data_DF['Date'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))


fig.update_traces(opacity=0.3)
fig.update_layout(bargap=0.5)
fig.update_layout(width=400)
fig.update_yaxes(title= 'I1')

fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/Clinton I1 confidence intervals.svg", format='svg',scale=2, engine='orca')



#Bush
Data_DF = pd.read_excel("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/input data/Schotthöfer 2024 Bush.xlsx")


#create go Figure
fig = go.Figure()

#Bush P1 Trace
fig.add_trace(go.Bar(
            name= 'Bush P1',
            y=Data_DF['Bush Upper P1']-Data_DF['Bush Lower P1'],
            x=Data_DF['Date'],
            base=Data_DF['Bush Lower P1'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

#Bush P1 means Trace
fig.add_trace(go.Scatter(
            name= 'Bush P1 means',
            y=Data_DF['Bush P1'],
            x=Data_DF['Date'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))


fig.update_traces(opacity=0.3)
fig.update_layout(bargap=0.5)
fig.update_layout(width=400)
fig.update_yaxes(title= 'P1')

fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/Bush P1 confidence intervals.svg", format='svg',scale=2, engine='orca')

#create go Figure
fig = go.Figure()

#Bush I1 Trace
fig.add_trace(go.Bar(
            name= 'Bush I1',
            y=Data_DF['Bush Upper I1']-Data_DF['Bush Lower I1'],
            x=Data_DF['Date'],
            base=Data_DF['Bush Lower I1'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))

#Bush I1 means Trace
fig.add_trace(go.Scatter(
            name= 'Bush I1 means',
            y=Data_DF['Bush I1'],
            x=Data_DF['Date'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)
        )))


fig.update_traces(opacity=0.3)
fig.update_layout(bargap=0.5)
fig.update_layout(width=400)
fig.update_yaxes(title= 'I1')

fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/Bush I1 confidence intervals.svg", format='svg',scale=2, engine='orca')

''' DISTRUST '''
Data_DF = pd.read_excel("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/input data/Schotthöfer 2024 Distrust.xlsx")

#create go Figure
fig = go.Figure()



#Bush DIS Trace
fig.add_trace(go.Bar(
            name= 'Bush',
            y=Data_DF['Bush Upper DIS']-Data_DF['Bush Lower DIS'],
            x=['Bush'],
            base=Data_DF['Bush Lower DIS'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)),
            showlegend=False
        ))

#Bush DIS mean Trace
fig.add_trace(go.Scatter(
            name= 'Bush',
            y=Data_DF['Bush DIS'],
            x=['Bush'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)),
            showlegend=False
        ))

#Clinton DIS Trace
fig.add_trace(go.Bar(
            name= 'Clinton',
            y=Data_DF['Clinton Upper DIS']-Data_DF['Clinton Lower DIS'],
            x=['Clinton'],
            base=Data_DF['Clinton Lower DIS'],
            #orientation='h',
            marker=dict(
                line=dict(
                    color='black',
                    width=2)),
            showlegend=False
        ))

#Clinton DIS mean Trace
fig.add_trace(go.Scatter(
            name= 'Clinton',
            y=Data_DF['Clinton DIS'],
            x=['Clinton'],
            marker=dict(
                line=dict(
                    color='black',
                    width=2)),
            showlegend=False
        ))

fig.update_traces(opacity=0.3)
fig.update_layout(bargap=0.5, width=300)
fig.update_yaxes(title= 'Distrust')

fig.show()

fig.write_image("C:/Michael/Albany LAIO Lab and Research Projects/Is a profile worth/images/DIS confidence intervals.svg", format='svg',scale=2, engine='orca')